#include <stdio.h>
#include <iostream>
#include <string>
#include <list>
#include "bigint\BigIntegerLibrary.hh"

int table[255];
int numbers[] = {57, 71, 87, 97, 99, 101, 103, 113, 114, 115, 128, 129, 131, 137, 147, 156, 163, 186 };

int main()
{
	FILE* file = fopen("stepic_dataset.txt", "r");
	FILE* table_file = fopen("integer_mass_table.txt", "r");
	FILE* out = fopen("result.txt", "w");
	
	int num;
	fscanf(file, "%d", &num);
	BigInteger* current = new BigInteger[num];
	BigInteger* prev = new BigInteger[num];
	for (int i=0; i<num; i++)
	{
		prev[i] = 0;
		current[i] = 0;
	}

	for (int i=0; i<18; i++)
	{
		int n = numbers[i];
		prev[n] = prev[n] + 1;
	}
	BigInteger result = 0;
	while (true)
	{
		for (int i=0; i<num; i++)
		{
			if (prev[i] > 0)
			{
				for (int j=0; j<18; j++)
				{
					int cur = i + numbers[j];
					if (cur < num) {
						current[cur] = current[cur] + prev[i];
					} else if (cur == num) {
						result = result + prev[i];
					}
				}
			}
		}
		bool flag = true;
		for (int i=0; i<num; i++)
		{
			prev[i] = 0;
			if (current[i] > 0)
				flag = false;
		}
		if (flag)
			break;
		std::swap(prev, current);
	}
	std::cout << result << std::endl;
	return 0;
}